Conversation
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
TrixiShallowWater.jl/src/equations/hyperbolic_sainte_marie_1d.jl
Lines 221 to 222 in 470f555
[JuliaFormatter] reported by reviewdog 🐶
TrixiShallowWater.jl/src/equations/hyperbolic_sainte_marie_1d.jl
Lines 226 to 227 in 470f555
[JuliaFormatter] reported by reviewdog 🐶
TrixiShallowWater.jl/src/equations/hyperbolic_sainte_marie_1d.jl
Lines 231 to 234 in 470f555
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
==========================================
+ Coverage 99.28% 99.30% +0.02%
==========================================
Files 96 98 +2
Lines 5146 5290 +144
==========================================
+ Hits 5109 5253 +144
Misses 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @doc raw""" | ||
| HyperbolicSainteMarieEquations1D(; bathymetry_type = bathymetry_mild_slope, | ||
| gravity, | ||
| eta0 = 0.0, | ||
| h0, | ||
| alpha = 3.0) | ||
|
|
||
| Hyperbolic approximation of the Sainte-Marie system | ||
| [`SainteMarieEquations1D`](@ref) in one spatial dimension |
There was a problem hiding this comment.
Please fix the docstring so that it matches the code here and not DispersiveShallowWater.jl.
| function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity), | ||
| b0 = one(gravity), alpha = 3, | ||
| threshold_limiter = nothing) | ||
| T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha)) | ||
| if threshold_limiter === nothing | ||
| threshold_limiter = 500 * eps(T) | ||
| end | ||
| celerity = alpha * sqrt(gravity * b0) |
There was a problem hiding this comment.
I think we should not use b0 to determine the hyperbolization parameter, since Escalante et al. use a reference water height h_0 (and the exact value of the bathymetry b can be changed arbitrarily by moving everything in the vertical direction).
H0 should also not be used since it is a reference for the surface elevation h + b, correct? Maybe we need to introduce another argument, h0, although this can be confusing...
There was a problem hiding this comment.
Would it make sense to use H0 - b0 for the reference water height?
There was a problem hiding this comment.
Yes - but b0 is not used otherwise. Thus, it would be more straightforward to use another parameter name for it, wouldn't it?
There was a problem hiding this comment.
Ah, yes if b0 is not used otherwise I agree it makes more sense to use another parameter name.
There was a problem hiding this comment.
What about using something like h_ref or eta0?
There was a problem hiding this comment.
I am fine with h_ref and h_0. The docstring is talking about h_0. So why not that?
There was a problem hiding this comment.
I am in favor of h_ref because with h_0 I would expect the relation H_0 = b + h_0 to hold.
| """ | ||
| flux_conservative_ec(u_ll, u_rr, normal_direction::AbstractVector, equations::HyperbolicSainteMarieEquations1D) | ||
|
|
||
| Total energy conserving and well-balanced two-point flux by | ||
| - Marco Artiano, Hendrik Ranocha (2026) | ||
| On Affordable High-Order Entropy-Conservative/Stable and | ||
| Well-Balanced Methods for Nonconservative Hyperbolic Systems | ||
| [DOI: 10.48550/arXiv.2603.18978](https://arxiv.org/abs/2603.18978) | ||
| """ | ||
| struct flux_conservative_ec{RealT <: Real} |
There was a problem hiding this comment.
Structs should have capital names like FluxConservativeEC. Please also adapt the docstring to describe what the parameters alpha1, alpha2, alpha3 mean, and how the flux can be applied.
It would also be possible to just pick one set of parameters that performs well and stick with it instead of implementing the whole family. I don't have a strong opinion on this. Since performance is not critical right now, it is definitely nice to have the flexibility - but we may recommend some reasonable default value.
There was a problem hiding this comment.
I've fixed the structs' name and adapted the docstrings. We may recommend alpha_1 = 1.0, alpha_2 = 0, alpha_3 = 0, which corresponds to the split form of the shallow water terms and strong form of the remaining terms. Eventually also alpha_1 = 1.0, alpha_2 = 1.0, alpha_3 = 1.0 works (as informative example), which results in a split form for all the terms.
| # Convert conservative variables to entropy | ||
| # Note, only the first two are the entropy variables, the third entry still | ||
| # just carries the bottom topography values for convenience | ||
| @inline function Trixi.cons2entropy(u, equations::HyperbolicSainteMarieEquations1D) | ||
| h, h_v, h_w, h_p, b = u | ||
|
|
||
| v = h_v / h | ||
| w = h_w / h | ||
| p = h_p / h | ||
|
|
||
| w1 = equations.gravity * (h + b) - 0.5f0 * (v^2 + w^2 + p^2 / equations.celerity^2) | ||
| w2 = v | ||
| w3 = w | ||
| w4 = p / equations.celerity^2 | ||
| return SVector(w1, w2, w3, w4, zero(eltype(u))) | ||
| end |
There was a problem hiding this comment.
The comment about the bottom topography and the code do not match.
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
…work/TrixiShallowWater.jl into ma/hyperbolized_sainte_marie
JoshuaLampert
left a comment
There was a problem hiding this comment.
Looks mostly good to me. It might make sense to also implement a flux function computing the analytical flux because it enables using, e.g., LLF.
| if threshold_limiter === nothing | ||
| threshold_limiter = 500 * eps(T) | ||
| end | ||
| celerity = alpha * sqrt(gravity * b0) |
There was a problem hiding this comment.
Since we only need the squared celerity it probably makes sense to also just store the square.
| function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity), | ||
| b0 = one(gravity), alpha = 3, | ||
| threshold_limiter = nothing) | ||
| T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha)) | ||
| if threshold_limiter === nothing | ||
| threshold_limiter = 500 * eps(T) | ||
| end | ||
| celerity = alpha * sqrt(gravity * b0) |
There was a problem hiding this comment.
I am fine with h_ref and h_0. The docstring is talking about h_0. So why not that?
patrickersing
left a comment
There was a problem hiding this comment.
Thanks for adding this new system! That is a really nice addition to the package.
The implementation looks quite good already, I mainly had suggestions about naming conventions and comments.
Could you please also:
- Add a convergence test and document convergence result in the PR.
- Add equation specific unit tests such as https://github.com/trixi-framework/TrixiShallowWater.jl/blob/main/test/test_unit.jl#L26.
- Create an entry to
NEWS.mdabout the addition.
| # semidiscretization of the shallow water equations with a discontinuous | ||
| # bottom topography function for a fully wet configuration |
There was a problem hiding this comment.
| # semidiscretization of the shallow water equations with a discontinuous | |
| # bottom topography function for a fully wet configuration | |
| # semidiscretization of the hyperbolic sainte-marie equations for a smooth and periodic initial condition to test entropy conservation |
|
|
||
| alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
|
||
| stepsize_callback = StepsizeCallback(cfl = 0.1) |
There was a problem hiding this comment.
The stepsize callback is defined but not included in the CallbackSet.
| The additional quantity ``H_0`` is also available to store a reference value for the total water height that | ||
| is useful to set initial conditions or test the "lake-at-rest" well-balancedness. | ||
| Escalante, Dumbser and Castro (2019) choose the hyperbolization parameter as ``c = \alpha \sqrt{g h_0}`` for some background water height ``h_0``. | ||
| Thus, the hyperbolization parameter ``c^2`` is set by the keyword arguments `alpha` (``\alpha``), `gravity` (``g``), and `h0` (``h_0``). |
There was a problem hiding this comment.
Just a reminder to make the variable name h_0 consistent to the function argument once we settled on a name.
| function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity), | ||
| b0 = one(gravity), alpha = 3, | ||
| threshold_limiter = nothing) | ||
| T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha)) | ||
| if threshold_limiter === nothing | ||
| threshold_limiter = 500 * eps(T) | ||
| end | ||
| celerity = alpha * sqrt(gravity * b0) |
There was a problem hiding this comment.
I am in favor of h_ref because with h_0 I would expect the relation H_0 = b + h_0 to hold.
| gravity::RealT | ||
| H0::RealT | ||
| celerity::RealT | ||
| threshold_limiter::RealT |
There was a problem hiding this comment.
Since there is not wet/dry functionality implemented, you can remove threshold_limiter for the equation.
| @inline function source_term_hyperbolic_sainte_marie(u, x, t, | ||
| equations::HyperbolicSainteMarieEquations1D) |
There was a problem hiding this comment.
Please add a docstring to explain the usage of this source term.
This is not optional, but a fundamental part of the equations right?
| end | ||
|
|
||
| """ | ||
| FluxConservativeEC(alpha_1, alpha_2, alpha_3)(u_ll, u_rr, normal_direction::AbstractVector, equations::HyperbolicSainteMarieEquations1D) |
There was a problem hiding this comment.
The function name FluxConservativeEC is kept very general. I would prefer to stick with the standard naming convention and name it FluxArtianoEtal and FluxNonconservativeArtianoEtal.
We also use alpha when we determine the hyperbolization parameter. What do you think about changing one of the parameter names to beta to differ between them?
There was a problem hiding this comment.
Well, alpha_i was used in the paper. Thus, we would at least have to describe this difference from the paper.
Moreover, alpha is already used in several places, e.g., for the shock-capturing parameter. However, I do not have a very strong opinion on this; it's your decision what you would like to have in TrixiShallowWater.jl.
| In the formal limit ``c^2 \to \infty``, the hyperbolic approximation recovers the original Sainte-Marie system. | ||
| The additional quantity ``H_0`` is also available to store a reference value for the total water height that | ||
| is useful to set initial conditions or test the "lake-at-rest" well-balancedness. | ||
| Escalante, Dumbser and Castro (2019) choose the hyperbolization parameter as ``c = \alpha \sqrt{g h_0}`` for some background water height ``h_0``. |
There was a problem hiding this comment.
I would suggest to name this c_ref or c_hyp as we use the variable c already, when we compute the wave celerity in max_abs_speeds.
There was a problem hiding this comment.
c_ref sounds good and would be in accordance with h_ref 👍
| end | ||
|
|
||
| # Helper function to extract the velocity vector from the conservative variables | ||
| @inline function Trixi.velocity(u, equations::HyperbolicSainteMarieEquations1D) |
There was a problem hiding this comment.
Should this also extract the vertical velocity?
There was a problem hiding this comment.
I would not do so. Right now, the velocity dimension is in accordance with the spatial dimensions of the equations. Moreover, the equations do not really model transport in the vertical direction (just resulting vertical velocity coming from the background incompressible Euler system).
| H0_wet_dry = max(equations.H0, b + equations.threshold_limiter) | ||
|
|
||
| return abs(H0_wet_dry - (h + b)) |
There was a problem hiding this comment.
| H0_wet_dry = max(equations.H0, b + equations.threshold_limiter) | |
| return abs(H0_wet_dry - (h + b)) | |
| return abs(equations.H0 - (h + b)) |
If we don't consider wetting and drying this can be simplified.
The entropy conserving and well-balanced scheme is derived in https://arxiv.org/abs/2603.18978.